//
//  BaiduAdView.m
//  DayDay
//
//  Created by wade on 16/5/20.
//  Copyright © 2016年 wade. All rights reserved.
//

#import "BaiduAdView.h"

@implementation BaiduAdView


-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];// 先调用父类的initWithFrame方法
    if (self) {
        
        BaiduMobAdView *sharedAdView1 = [[BaiduMobAdView alloc] init]; //把在mssp.baidu.com上创建后获得的代码位id写到这里
        sharedAdView1.AdUnitTag = BaiduMobAdViewID;
        sharedAdView1.AdType = BaiduMobAdViewTypeBanner;
        sharedAdView1.frame = self.frame;
        sharedAdView1.delegate = self;
        [sharedAdView1 start];
        [self addSubview:sharedAdView1];
        
    }
    return self;
}

- (NSString *)publisherId
{
    return  PublisherId; //@"your_own_app_id";
}

-(BOOL) enableLocation
{
    //启用location会有一次alert提示,请根据系统进行相关配置
    return NO;
}

/*********************************** banner广告 ****************************************/

/**
 *  广告将要被载入
 */
-(void) willDisplayAd:(BaiduMobAdView*) adview
{
    NSLog(@"will display ad");
}

/**
 *  广告载入失败
 */
-(void) failedDisplayAd:(BaiduMobFailReason) reason;
{
    NSLog(@"failedDisplayAd %d", reason);
}

/**
 *  本次广告展示成功时的回调
 */
-(void) didAdImpressed
{
    NSLog(@"didAdImpressed");
}

/**
 *  本次广告展示被用户点击时的回调
 */
-(void) didAdClicked
{
    NSLog(@"didAdClicked");
}

/**
 *  在用户点击完广告条出现全屏广告页面以后，用户关闭广告时的回调
 */
-(void) didDismissLandingPage
{
    NSLog(@"didDismissLandingPage");
}


/*********************************** banner广告 ****************************************/

@end
